package bag.service.impl;

import bag.c3p0Untils.PageBean;
import bag.dao.ProductDao;
import bag.dao.impl.ProductDaoImpl;
import bag.domain.Product;
import bag.service.CartService;
import org.apache.commons.dbutils.QueryRunner;

import java.sql.SQLException;
import java.util.List;

/**
 * Created by 冷丶 on 2017/10/24.
 */
public class CartServiceImpl implements CartService{

    @Override
    public List<Product> findAll() {
        ProductDao dao = new ProductDaoImpl();
        return dao.findAll();
    }

    @Override
    public int updateById(Product product) {
        ProductDao dao = new ProductDaoImpl();
        return dao.updateById(product);
    }


    @Override
    public Product findById(String pid) {
        ProductDao dao = new ProductDaoImpl();
        return dao.findById(pid);
    }

    @Override
    public boolean deleteById(String pid) throws SQLException {
        ProductDao dao = new ProductDaoImpl();
        return dao.deleteById(pid);
    }

    @Override
    public int insert(Product product) throws SQLException {
        ProductDao dao = new ProductDaoImpl();
        return dao.insert(product);
    }

    @Override
    public List<Product> findByCondition(String condition) {
        ProductDao dao = new ProductDaoImpl();
        return dao.findByCondition(condition);
    }

    @Override
    public PageBean<Product> findPage(int currentPage, int pageSize) {
        ProductDao dao = new ProductDaoImpl();
        return dao.findPage(currentPage,pageSize);
    }
}
